﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConsoleApp1;

namespace Mainform
{
    public class OrderFormService
    {
        private readonly OrderService _orderService;

        public OrderFormService(OrderService orderService)
        {
            _orderService = orderService;
        }

        public BindingList<Order> GetOrderBindingList()
        {
            return new BindingList<Order>(_orderService.GetAllOrders());
        }

        public void SaveOrder(Order order, bool isNew)
        {
            if (isNew)
            {
                _orderService.AddOrder(order);
            }
            else
            {
                _orderService.UpdateOrder(order);
            }
        }

        public void DeleteOrder(string orderId)
        {
            _orderService.RemoveOrder(orderId);
        }
    }
}
